package com.hadoop.test;

import java.io.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * <p></p>
 *
 * @author Andy
 * @date 2017/9/23
 */
public class SerialCtl implements Serializable {
    String a;
    transient String b;

    public SerialCtl(String aa, String bb) {
        a = "Not Transient:" + aa;
        b = "Transient:" + bb;
    }

    @Override
    public String toString() {
        return a + "\n" + b;
    }

    private void writeObject(ObjectOutputStream o) throws IOException {
        o.defaultWriteObject();
       // o.writeObject(b);
    }

    private void readObject(ObjectInputStream streamr) throws IOException, ClassNotFoundException {
        streamr.defaultReadObject();
        //b = (String) streamr.readObject();
    }

    public static void main(String[] args) {
        /*SerialCtl sc = new SerialCtl("Test1", "Test2");
        System.out.println("Before:\n" + sc);
        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        try {
            ObjectOutputStream out1 = new ObjectOutputStream(buf);
            out1.writeObject(sc);

            ObjectInputStream in1 = new ObjectInputStream(new ByteArrayInputStream(buf.toByteArray()));
            SerialCtl sc2 = (SerialCtl) in1.readObject();
            System.out.println("After:\n" + sc2);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }*/
       /* List<Integer> list = new ArrayList<>();
        *//*for(int i = 0 ; i< list.size();i++) {
            System.out.println("=====for=====");
            System.out.println(list.get(i));
        }*//*

        for (Integer id : list) {
            System.out.println("========foreach========");
            System.out.println(id);
        }*/
        //Test t = new Test(10);
      /*  Employee e = new Employee();
        Employee employee = Employee.getInstance();
        System.out.println(employee);

        Employee employee1 = Employee.getInstance();
        System.out.println(employee == employee1);*/
        Map<String, Integer> map = new HashMap<>();
        map.put(null,null);
        map.put(null, 123);
        System.out.println(map);

        Map<String, Integer> map1 = new Hashtable<>();
        map1.put("ssd", 12);
        System.out.println(map1);

        Map<String, Integer> map2 = new ConcurrentHashMap<>();
        map2.put("te", 1285);
        System.out.println(map2);

    }

}

class Test {
    private String userName = "test";
    private static final int tt = 20;
    private static String password = "123456";
    private int age;

    Test() {
    }

    Test(int age) {
        this.age = age;
        System.out.println(userName+"\t"+password + "\t"+age+"\t"+tt);
    }

    static{
        System.out.println("==========");
        System.out.println(password);
        System.out.println(tt);
    }
}

class Employee{
    private volatile static Employee employee;

    public static Employee getInstance() {
        if (employee == null) {
            synchronized(Employee.class){
                if (employee == null) {
                    employee = new Employee();
                }
            }
        }
        return employee;
    }
}
